import { connect } from 'dva'

import AekTable from '@/components/AekTable'
import PageLayout from '@/components/PageLayout'
import { namespace } from '@/models/pcs/feedback'
import { getPagination } from '@/utils/antdHelper'
import { getBasicFn } from '@/utils/dvaUtil/index'

/** 陪护 - 需求反馈管理 */
const Index = ({ modelState, loading }) => {
  const { pageList, pagination } = modelState
  const { toAction, getLoading } = getBasicFn({ namespace, loading })

  /** @type {import("@/components/AekTable").AekTableProps} */
  const tableProps = {
    configKey: namespace,
    rowKey: 'id',
    loading: getLoading('getPageList'),
    dataSource: pageList,
    pagination: getPagination(pagination, (current, pageSize) => {
      toAction('getPageList', { current, pageSize })
    }),
    columns: [
      { dataIndex: 'message', title: '反馈内容' },
      { dataIndex: 'phone', title: '联系方式' },
      { dataIndex: 'createTime', title: '反馈时间', isDateTime: true },
    ],
  }

  return (
    <PageLayout>
      <AekTable {...tableProps} />
    </PageLayout>
  )
}

export default connect(store => ({
  modelState: store[namespace],
  loading: store.loading,
}))(Index)
